package com.web.biz.brandweb.service;
import java.util.HashMap;

import com.css.sword.kernel.base.annotation.Service;
import com.css.sword.kernel.base.annotation.ServiceContainer;
import com.css.sword.kernel.base.persistence.IPersistenceService;
import com.css.sword.kernel.base.persistence.SQLParam;
import com.css.sword.kernel.utils.SwordLogUtils;
import com.css.sword.kernel.utils.SwordPersistenceUtils;
import com.css.sword.platform.web.event.IReqData;
import com.css.sword.platform.web.event.IResData;
import com.css.sword.platform.web.event.SwordRes;
import com.web.common.dataDictionary.PO.TCategoryShopPO;
import com.web.common.utils.LoginInfoUtil;

@ServiceContainer
public class BrandWebXzdzService {

	private static SwordLogUtils log = SwordLogUtils.getLogger(BrandWebXzdzService.class);
	private final static String curpath = "/pages/biz/brand/";
	public BrandWebXzdzService() throws Exception {
		super();
	}


	/**
	 * 商户更新下载地址
	 */
	@Service(serviceName = "BrandWebXzdzService_updateXzdz")
	public IResData updateXzdz(IReqData req) throws Exception {

		

		log.debug("开始进入 BrandWebXzdzService_updateXzdz 方法。");

		IPersistenceService dao = SwordPersistenceUtils.getPersistenceService();
		IResData res = new SwordRes();
		String szflag = "false";
		try {
			TCategoryShopPO shopPO = (TCategoryShopPO) req.getForm("form_brandxzdz",TCategoryShopPO.class);
			if (dao.updatePO(shopPO)>=0) {
				szflag = "true";
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		
		res.addAttr("szflag", szflag);
		return res;
	}

	 		
	/**
	 * 初始化下载地址表单
	 */
	@Service(serviceName = "BrandWebXzdzService_initXzdzForm")
	public IResData initXzdzForm(IReqData req) throws Exception {

		log.debug("开始进入 BrandWebXzdzService_initXzdzForm 方法。");

		IPersistenceService dao = SwordPersistenceUtils.getPersistenceService();

		IResData res = new SwordRes();
		SQLParam param = new SQLParam();
		param.addParam(LoginInfoUtil.getLoginUserName());
		TCategoryShopPO shopPO = dao.queryPOByKey("grxx_queryShopxxByYhm", param, TCategoryShopPO.class);
		HashMap<String, Object> map = new HashMap<String, Object>();
		map.put("cBrandId", shopPO.getCBrandId().value);
		map.put("appAndroid", shopPO.getAppAndroid().value);
		map.put("appIos", shopPO.getAppIos().value);
		res.addForm("form_brandxzdz", map);
		
		res.addPage(curpath+"brandWebXzdzForm.jsp");
		return res;

	}

	 		


}